package com.tjsinfo.tjsoa.vote.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.vote.bo.ITVoteEstimatedBO;
import com.tjsinfo.tjsoa.vote.vo.TVoteEstimated;

public class EsimatedAddAction extends Action {
	private ITVoteEstimatedBO estimatedBo;

	public void setEstimatedBo(ITVoteEstimatedBO estimatedBo) {
		this.estimatedBo = estimatedBo;
	}
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		try {
			String headId = request.getParameter("headId");
			String status = request.getParameter("status");
			
			TVoteEstimated tve = new TVoteEstimated();
			tve.setHeadId(headId);
			tve.setName(request.getParameter("name"));
			tve.setPost(request.getParameter("post"));
			tve.setOrderId(Integer.parseInt(request.getParameter("orderId")));
			estimatedBo.save(tve);
			
			request.setAttribute("linkurl", "tjsinfo/tjsoa/vote/estimatedList.do?headId="+headId+"@status="+status);
			request.setAttribute("message", "vote.estimateAdd.message");
			return mapping.findForward("success");
		} catch (Exception e) {
			e.printStackTrace();
			return mapping.findForward("failed");
		}
	}

}
